import { app, BrowserWindow } from 'electron'
import path from 'path'

function createWindow() {
    const mainWindow = new BrowserWindow({
        width: 800,
        height: 600
    })

    if(app.isPackaged){
        mainWindow.loadFile(path.join(__dirname, '../index.html'))
    }
    else{
        mainWindow.loadURL(process.env['VITE_DEV_SERVER_URL']!)
    }
}

app.whenReady().then(() => {
    createWindow()

    app.on('activate', function () {
        if (BrowserWindow.getAllWindows().length === 0) createWindow()
    })
})

app.on('window-all-closed', function () {
    if (process.platform !== 'darwin') app.quit()
})


